/**
 * 选中一组checkbox
 * 
 * @param eleName
 */
function checkAllCheckBox(eleName) {
	$("input[name='" + eleName + "']").each(function() {
		$(this).attr("checked", "checked");
	});
}
/**
 * 取消选中一组checkbox
 * 
 * @param eleName
 */
function uncheckAllCheckBox(eleName) {
	$("input[name='" + eleName + "']").each(function() {
		$(this).removeAttr("checked");
	});
}
/**
 * 获取一组checkbox选中的值
 * 
 * @param eleName
 * @returns {String}
 */
function getCheckboxVal(eleName) {
	var admin_add_accountidgroup = "";
	var len = $("input[name='" + eleName + "']").size();
	for ( var i = 0; i < len; i++) {
		var tmp = $("input[name='" + eleName + "']").eq(i);
		if (tmp.attr("checked") == "checked") {
			admin_add_accountidgroup += tmp.val() + ",";
		}
	}
	if (admin_add_accountidgroup != "") {
		admin_add_accountidgroup = admin_add_accountidgroup.substring(0,
				admin_add_accountidgroup.length - 1);
	}
	return admin_add_accountidgroup;
}

/**
 * 生成分页的链接
 * 
 * @param pageNo
 * @param totalPage
 * @param functionName
 * @param otherParamsStr
 * @returns {String}
 */
function genderPageStr(pageNo, pageSize, totalPage, functionName,
		otherParamsStr) {
	// <a href="#">上一页</a>&nbsp; 1/2 <a href="#">下一页</a>&nbsp;
	var lessPageNo = pageNo - 1;
	var nextPageNo = pageNo + 1;
	var html = '';
	if (totalPage > 0) {
		html += '<a href="javascript:void(0);" onclick="'
				+ genderPageFunctionStr(lessPageNo, pageSize, totalPage,
						functionName, otherParamsStr) + '">上一页</a>&nbsp; ';
		html += pageNo + "/" + totalPage;
		html += ' <a href="javascript:void(0);" onclick="'
				+ genderPageFunctionStr(nextPageNo, pageSize, totalPage,
						functionName, otherParamsStr) + '">下一页</a>&nbsp;';
	}
	return html;
}
/**
 * 生成链接
 * 
 * @param pageNo
 * @param totalPage
 * @param functionName
 * @param otherParamsStr
 * @returns {String}
 */
function genderPageFunctionStr(pageNo, pageSize, totalPage, functionName,
		otherParamsStr) {
	if (pageNo < 1 || pageNo > totalPage) {
		return "javascript:void(0);";
	}
	return functionName + "(" + pageNo + "," + pageSize + "," + otherParamsStr
			+ ")";
}
/**
 * 将一个简单的对象转成json串，仅供简单使用，复杂对象有问题
 * 
 * @param obj
 * @returns {String}
 */
function Serialize(obj) {
	switch (obj.constructor) {
	case Object:
		var str = "{";
		for ( var o in obj) {
			str += o + ":" + Serialize(obj[o]) + ",";
		}
		if (str.substr(str.length - 1) == ",")
			str = str.substr(0, str.length - 1);
		return str + "}";
		break;
	case Array:
		var str = "[";
		for ( var o in obj) {
			str += Serialize(obj[o]) + ",";
		}
		if (str.substr(str.length - 1) == ",")
			str = str.substr(0, str.length - 1);
		return str + "]";
		break;
	case Boolean:
		return "\"" + obj.toString() + "\"";
		break;
	case Date:
		return "\"" + obj.toString() + "\"";
		break;
	case Function:
		break;
	case Number:
		return "\"" + obj.toString() + "\"";
		break;
	case String:

		return "\"" + obj.toString() + "\"";
		break;
	}
}
/**
 * 对string对象扩展startWith方法
 * 
 * @param s
 * @returns {Boolean}
 */
String.prototype.startWith = function(s) {
	if (s == null || s == "" || this.length == 0 || s.length > this.length)
		return false;
	if (this.substr(0, s.length) == s)
		return true;
	else
		return false;
	return true;
}